package com.itheima.tlias84.mapper;

import com.itheima.tlias84.entity.Stu;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StuMapper {
//增删改查(五个接口)、批量删除、新增，记得用apifox测试下

    @Insert("insert into stu(name,gender,age,address,school,create_time,update_time)" +
            "values (#{s.name},#{s.gender},#{s.age},#{s.address},#{s.school},#{s.createTime},#{s.updateTime})")
    int insertStu(@Param("s") Stu student);

    @Delete("delete from stu where id = #{id}")
    int deleteStuById(@Param("id") Integer id);

    @Update("update stu set name = #{s.name},gender = #{s.gender},age = #{s.age},address = #{s.address}," +
            "school =#{s.school},create_time=#{s.createTime},update_time=#{s.updateTime} where id = #{s.id}" )
    int updateStuById(@Param("s") Stu student);

    @Select("select * from stu where id = #{id}")
    Stu selectStuById(@Param("id") Integer id);

    @Select("select * from stu")
    List<Stu> selectAllStudent();


    int batchDelete(@Param("ids") List<Integer> ids);

    int insertStuBatch(@Param("list") List<Stu> list);
}
